package www.rlicker.service.impl;

import www.rlicker.model.Product;
import java.util.Map;
import javax.annotation.Resource;
import www.rlicker.dao.IProductDao;
import org.springframework.stereotype.Service;
import www.rlicker.mybatis.Criteria;
import www.rlicker.service.IProductService;
import www.rlicker.utils.TranslateToMap;
import java.util.List;

/**
 * 
 * Product鏁版嵁搴撴搷浣滄帴鍙ｇ被
 * 
 **/

@Service
public class ProductServiceImpl implements IProductService{


	/**
	 * 
	 * 鍒嗛〉鏌ヨ
	 * 
	 **/
	public List<Map<String, Object>>  queryPage (Criteria<Product> param){
		List<Product> list = productRepository.queryPage(param);
			List<Map<String,Object>> map = TranslateToMap.convertListBean2ListMap(list,Product.class);
	return map;  }

	/**
	 * 
	 * 鍒嗛〉鎬绘暟鏌ヨ
	 * 
	 **/
	public Integer queryPageCount (Criteria<Product> param){
		return (Integer) productRepository.queryPageCount(param);
	}

	/**
	 * 
	 * 鏌ヨ锛堟牴鎹富閿甀D鏌ヨ锛�
	 * 
	 **/
	public Product  queryEntity (Integer id ){
		return productRepository.queryEntity(id);
	}

	/**
	 * 
	 * 鍒犻櫎锛堟牴鎹富閿甀D鍒犻櫎锛�
	 * 
	 **/
	public String deleteById (Integer id ){
		int result = productRepository.deleteById(id);
			if ( result != 1) {
					return null;
			}
			return null;
	}

	/**
	 * 
	 * 娣诲姞 锛堝尮閰嶆湁鍊肩殑瀛楁锛�
	 * 
	 **/
	public String insert(Product record ){
		int result = productRepository.insert(record);
			if ( result != 1) { 
					return null;
			}
			return null;
	}

	/**
	 * 
	 * 淇敼锛堝尮閰嶆湁鍊肩殑瀛楁锛�
	 * 
	 **/
	public String update (Criteria<Product> param){
		int result = productRepository.update(param);
			if ( result != 1) { 
					return null;
			}
			return null;
	}

	@Resource
	private IProductDao productRepository;

}